package com.hulk.rpc.loadbalance;

import cn.hutool.core.util.ObjectUtil;
import com.google.common.hash.Hashing;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author xuxukang
 */
@Data
@Accessors(chain = true)
public class VirtualWeightable<T extends Weightable> {

  private T resource;
  private int virtualId;

  @Override
  public int hashCode() {
    return Hashing.goodFastHash(32).hashBytes(ObjectUtil.serialize(resource)).hashCode();
  }

}
